﻿@model Sitecore.Models.Book

@{
    ViewBag.Title = "Edit";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2>Edit</h2>

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

@using (Html.BeginForm())
{
    @Html.ValidationSummary(false)
    <fieldset>
    <legend>Authors</legend>
        @Html.ActionLink("+ author", "Edit", new { authorsCount = (int)Html.ViewData["authorsCount"] + 1 })
    @for (int i = 0; i < Model._Authors.Count(); i++)
    {
        <div class="editor-label">
            @Html.LabelFor(model => model._Authors[i])
        </div>
            <div class="editor-label">
            @Html.LabelFor(model => model._Authors[i].FirstName)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model._Authors[i].FirstName)
            @Html.ValidationMessageFor(model => model._Authors[i].FirstName)
        </div>
        
        <div class="editor-label">
            @Html.LabelFor(model => model._Authors[i].LastName)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model._Authors[i].LastName)
            @Html.ValidationMessageFor(model => model._Authors[i].LastName)
        </div>
    }
        </fieldset>
        <fieldset>
        <legend>Book</legend>

        <div class="editor-label">
            @Html.LabelFor(model => model.Title)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Title)
            @Html.ValidationMessageFor(model => model.Title)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Year)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Year)
            @Html.ValidationMessageFor(model => model.Year)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Description)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Description)
            @Html.ValidationMessageFor(model => model.Description)
        </div>

        @Html.HiddenFor(model => model.ID)

        <p>
            <input type="submit" value="Save" />
        </p>
    </fieldset>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>
